package demo6;

import org.springframework.context.annotation.AnnotationConfigApplicationContext;

public class Demo {
    public static void main(String[] args) {
        AnnotationConfigApplicationContext context
        =new AnnotationConfigApplicationContext("demo6");
        /*
        在Spring容器内部，被管理的对象，是单例的
        因此无论向Spring容器获取多少次实例，返回的始终同一个对象
         */
        Person p1=context.getBean(Person.class);
        System.out.println(p1);
        Person p2=context.getBean(Person.class);
        System.out.println(p2);
        Student s1=context.getBean(Student.class);
        System.out.println(s1);
        Student s2=context.getBean(Student.class);
        System.out.println(s2);
    }
}
